package com.tyk.bookstore.front.auth.util;


import com.tyk.bookstore.front.common.core.model.constant.ValidateConstant;

public class ParamUtil {
    public static boolean checkAccount(String account) {
        return account != null && account.length() >= 2 && account.length() <= 20 && ValidateConstant.ACCOUNT_PATTERN.matcher(account).matches();
    }

    public static boolean checkPassword(String password) {
        return password != null && password.length() >= 2 && password.length() <= 20 && ValidateConstant.PASSWORD_PATTERN.matcher(password).matches();
    }

    public static boolean checkEmail(String email) {
        return email != null && email.length() >= 4 && email.length() <= 60 && ValidateConstant.EMAIL_PATTERN.matcher(email).matches();
    }

    public static boolean checkCode(String code) {
        return code != null && code.length() == 6 && ValidateConstant.CODE_PATTERN.matcher(code).matches();
    }

    public static boolean checkPhone(String phone) {
        return phone != null && phone.length() == 11 && ValidateConstant.PHONE_PATTERN.matcher(phone).matches();
    }
}
